package com.bipa.service;

import com.bipa.bean.Article;
import com.bipa.dao.ArticleDao;
import com.bipa.util.PagerModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("articleService")
public class ArticleService {

    @Autowired
    ArticleDao articleDao;

    public List<Article> findArticles(String typeCode, String keyword, PagerModel pagerModel){

        return articleDao.findArticles(typeCode,keyword,pagerModel.getStartSize(),pagerModel.getPageSize());
    }

    public List<Article> findArticles1(String typeCode, String keyword, PagerModel pagerModel){

        return articleDao.findArticles1(typeCode,keyword,pagerModel.getStartSize(),pagerModel.getPageSize());
    }

    public int getTotalNum(String typeCode, String keyword){
        return articleDao.findAll(typeCode,keyword).size();
    }

    public Article getArticleById(Integer id){
        return articleDao.getArticleById(id);
    }

    public void removeOrPutArticle(Integer id,Integer disabled){
        articleDao.removeOrPutArticle(id,disabled);
    }

    public void update(Article article){
        articleDao.update(article);
    }

    public void insert(Article article){
        articleDao.insert(article);
    }
}
